package com.briup.recognition.web.controller;

import com.briup.recognition.bean.Article;
import com.briup.recognition.service.IArticleService;
import com.briup.recognition.utils.Message;
import com.briup.recognition.utils.MessageUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("article")
public class ArticleController {
    @Resource
    private IArticleService articleService;

    @GetMapping("query")
    public Message query(){
        List<Article> list= articleService.query();
        return MessageUtil.success(list);

    }
    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate(Article article){
        articleService.saveOrUpdate(article);
        return MessageUtil.success("操作成功");
    }

    @DeleteMapping("deleteById")
    public Message deleteById(long id){
        articleService.deleteById(id);
        return MessageUtil.success("删除成功");

    }
}
